package com.peking.donations.base.log;

import com.peking.donations.base.util.SecurityUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>
 * 用户操作审计日志，用于用户重要操作的记录，例如：
 * 1.新增存款
 * 2.支付平台回调
 * 3.用户修改取现密码
 * 4.用户新增取现
 * 5.取现兑付
 * 6.修改用户信息
 * 7....
 *
 * @author hawk
 *
 */
public class UserAuditLog {

	public static final String SAVE = "SAVE";
	public static final String UPDATE = "UPDATE";
	public static final String DELETE = "DELETE";
	public static final String QUERY = "QUERY";
	public static final String ACTIVE = "ACTIVE";
	public static final String CANCEL = "CANCEL";
	public static final String LOAD = "LOADING";
	public static final String SENDMSG = "SENDMSG";///发送信息
	public static final String REPAY = "REPAY";//补发
	public static final String EXPORT = "EXPORT";
	public static final String SHOWCHART = "SHOWCHART";//
	public static final String WITHDRAW = "WITHDRAW";//取现
	public static final String RECHECK = "RECHECK";//复核
	public static final String REFUND = "REFUND";//退款
	public static final String CALCULATE = "CALCULATE";//计息
	public static final String BIND = "BIND";//绑定
	public static final String CHECK = "CHECK";//检查
	public static final String MARK = "MARK";//标记


	private static Logger logger = LoggerFactory.getLogger(UserAuditLog.class);

    /**
     * 注意：只能在WEB上下文使用（用户已登录时）
     * @param msg
     */
    public static void audit(String msg){
        String user = SecurityUtil.getCurrentUser().getUsername();
        audit(user, msg);
    }

    /**
     * 注意：只能在WEB上下文使用（用户未登录时）
     * @param username
     * @param msg
     */
    public static void audit(String username, String msg) {
        logger.info("opertoar:\t"+username+"\t message:"+msg);
    }
    
    public static void auditOper(String oper,String msg){
    	String user = SecurityUtil.getCurrentUser().getUsername();
    	auditOper(user, oper,msg);
    }
    
    public static void auditOper(String username,String oper, String msg) {
        logger.info("operator:"+username+"|"+oper+"|message:"+msg);
    }
}

